package com.mark.web.bill.entity.vo;

import com.mark.common.utils.DateTimeUtil;
import com.mark.web.bill.entity.po.GoodsCategory;
import com.mark.web.bill.enums.GoodsCategoryEnum;
import lombok.Data;

/**
 * @Description: 用户头像POJO类
 * @Author: Mark
 * @CreateDate: 2019/2/16 21:06
 * @Version: 2.0
 * @Copyright : 豆浆油条个人非正式工作室
 */
@Data
public class GoodsCategoryVo {

    private Integer id;

    private Integer parentId;

    private String goodsCategoryName;

    private String enableStatus;

    private Integer level;

    private Integer priority;

    private boolean hasParent;

    private String createTime;

    private String lastEditTime;

    public GoodsCategoryVo(GoodsCategory goodsCategory){
        this.id = goodsCategory.getId();
        this.parentId = goodsCategory.getParentId();
        //如果父级ID为0，则表示该种类没有父类，为种类信息的根种类
        this.hasParent = this.parentId == 0;
        this.goodsCategoryName = goodsCategory.getGoodsCategoryName();
        this.enableStatus = GoodsCategoryEnum.stateOf(goodsCategory.getEnableStatus());
        this.level = goodsCategory.getLevel();
        this.priority = goodsCategory.getPriority();
        this.createTime = DateTimeUtil.dateToStr(goodsCategory.getCreateTime());
        this.lastEditTime = DateTimeUtil.dateToStr(goodsCategory.getLastEditTime());
    }
}
